<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java并发编程 - JUC深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            padding: 20px;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 30px 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
        }
        
        .feature-card {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 16px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }
        
        .icon-wrapper {
            width: 60px;
            height: 60px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 20px;
        }
        
        .timeline-item {
            position: relative;
            padding-left: 40px;
            margin-bottom: 30px;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 10px;
            top: 0;
            bottom: -30px;
            width: 2px;
            background: #e0e0e0;
        }
        
        .timeline-item:last-child::before {
            display: none;
        }
        
        .timeline-dot {
            position: absolute;
            left: 0;
            top: 5px;
            width: 20px;
            height: 20px;
            background: #667eea;
            border-radius: 50%;
            border: 4px solid #fff;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
    </style>
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({ startOnLoad: true, theme: 'default' });
    </script>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">Java并发编程核心</h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">深入理解JUC框架，掌握高性能并发编程的艺术</p>
                <div class="flex justify-center space-x-4">
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-code mr-2"></i>专业级并发编程
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-rocket mr-2"></i>性能优化实践
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-shield-alt mr-2"></i>线程安全保障
                    </span>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction Section -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-3xl font-bold mb-6 section-title">JUC基础与核心概念</h2>
                <p class="text-lg leading-relaxed mb-6">
                    <span class="drop-cap">在</span>现代软件开发中，并发编程已经成为提升系统性能的关键技术。Java并发工具包（JUC）作为Java平台的核心组件，为开发者提供了强大而灵活的并发编程工具集。通过JUC，我们能够轻松应对高并发场景下的各种挑战，构建出高性能、高可靠性的应用系统。
                </p>
                
                <div class="grid md:grid-cols-3 gap-6 mt-10">
                    <div class="feature-card">
                        <div class="icon-wrapper">
                            <i class="fas fa-layer-group text-white text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3">线程池管理</h3>
                        <p class="text-gray-600">高效管理线程生命周期，避免频繁创建销毁带来的性能开销</p>
                    </div>
                    <div class="feature-card">
                        <div class="icon-wrapper">
                            <i class="fas fa-sync-alt text-white text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3">同步机制</h3>
                        <p class="text-gray-600">提供灵活的锁机制和同步工具，确保线程安全和数据一致性</p>
                    </div>
                    <div class="feature-card">
                        <div class="icon-wrapper">
                            <i class="fas fa-database text-white text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold mb-3">并发容器</h3>
                        <p class="text-gray-600">线程安全的数据结构，在高并发环境下保持优异性能</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- JUC Architecture Visualization -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-3xl font-bold mb-8 section-title">JUC架构体系</h2>
                <div class="mermaid">
                    graph TB
                        A[JUC并发框架] --> B[线程池框架]
                        A --> C[并发容器]
                        A --> D[同步工具]
                        A --> E[锁机制]
                        A --> F[原子操作]
                        
                        B --> B1[ThreadPoolExecutor]
                        B --> B2[ScheduledThreadPool]
                        B --> B3[ForkJoinPool]
                        
                        C --> C1[ConcurrentHashMap]
                        C --> C2[CopyOnWriteArrayList]
                        C --> C3[BlockingQueue]
                        
                        D --> D1[CountDownLatch]
                        D --> D2[CyclicBarrier]
                        D --> D3[Semaphore]
                        
                        E --> E1[ReentrantLock]
                        E --> E2[ReadWriteLock]
                        E --> E3[StampedLock]
                        
                        F --> F1[AtomicInteger]
                        F --> F2[AtomicReference]
                        F --> F3[LongAdder]
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                        style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style D fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style E fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style F fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </section>

        <!-- Core Components -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-3xl font-bold mb-8 section-title">核心组件详解</h2>
                
                <!-- Thread Pool -->
                <div class="mb-12">
                    <h3 class="text-2xl font-bold mb-4 flex items-center">
                        <i class="fas fa-server mr-3 text-gradient"></i>
                        线程池（Thread Pool）
                    </h3>
                    <p class="text-lg leading-relaxed mb-6">
                        线程池是JUC中最重要的组件之一，通过复用线程资源，避免了频繁创建和销毁线程的开销。合理配置线程池参数，能够显著提升系统的并发处理能力。
                    </p>
                    
                    <div class="highlight-box">
                        <h4 class="font-bold mb-3 text-lg">
                            <i class="fas fa-lightbulb mr-2 text-yellow-500"></i>
                            最佳实践
                        </h4>
                        <ul class="space-y-2 text-gray-700">
                            <li><i class="fas fa-check-circle mr-2 text-green-500"></i>CPU密集型任务：线程数 = CPU核心数 + 1</li>
                            <li><i class="fas fa-check-circle mr-2 text-green-500"></i>I/O密集型任务：线程数 = CPU核心数 × 2</li>
                            <li><i class="fas fa-check-circle mr-2 text-green-500"></i>使用有界队列避免OOM风险</li>
                            <li><i class="fas fa-check-circle mr-2 text-green-500"></i>合理设置拒绝策略处理任务溢出</li>
                        </ul>
                    </div>
                    
                    <div class="code-block mt-6">
                        <pre><code>// 创建自定义线程池
ExecutorService executor = new ThreadPoolExecutor(
    5,                      // 核心线程数
    10,                     // 最大线程数
    60L,                    // 空闲线程存活时间
    TimeUnit.SECONDS,       // 时间单位
    new LinkedBlockingQueue<>(100),  // 任务队列
    Executors.defaultThreadFactory(),
    new ThreadPoolExecutor.CallerRunsPolicy()  // 拒绝策略
);</code></pre>
                    </div>
                </div>

                <!-- Concurrent Collections -->
                <div class="mb-12">
                    <h3 class="text-2xl font-bold mb-4 flex items-center">
                        <i class="fas fa-cubes mr-3 text-gradient"></i>
                        并发容器（Concurrent Collections）
                    </h3>
                    <p class="text-lg leading-relaxed mb-6">
                        JUC提供的并发容器采用了分段锁、CAS等技术，在保证线程安全的同时，大幅提升了并发访问的性能。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-gray-50 rounded-lg p-6">
                            <h4 class="font-bold mb-3 text-lg">ConcurrentHashMap